package m.store.model;

import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;

import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name="ts_income_amount_record",description="收款金额记录")
public class IncomeAmountRecord extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("income.store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="income_oid",table= IncomeAmount.class,description="所属收款")
    private IncomeAmount income;
    @LinkTableMeta(name="sale_oid",table= SaleInfo.class,description="出库信息")
    private SaleInfo sale;
    @FieldMeta(name="income_amount",type= FieldType.DOUBLE,defaultValue = "0",description="收款金额")
    private Double incomeAmount;
    @FieldMeta(name = "remark",type = FieldType.STRING,length = 500,description = "备注")
    private String remark;

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public IncomeAmount getIncome() {
        return income;
    }

    public void setIncome(IncomeAmount income) {
        this.income = income;
    }

    public SaleInfo getSale() {
        return sale;
    }

    public void setSale(SaleInfo sale) {
        this.sale = sale;
    }

    public Double getIncomeAmount() {
        return incomeAmount;
    }

    public void setIncomeAmount(Double incomeAmount) {
        this.incomeAmount = incomeAmount;
    }
}
